--[[
Author: your name
Date: 2020-12-01 11:04:21
LastEditTime: 2020-12-01 20:34:54
LastEditors: your name
Description: In User Settings Edit
FilePath: \Lua\View\CharactorUI\UICharactorInfoArchivesItem.lua
--]]
require 'Common/define'
require 'Logic/Config'
require 'Common/functions'

UICharactorInfoArchivesItem = {};
HelperFunc.SetUIEnv(UICharactorInfoArchivesItem)
local this = UICharactorInfoArchivesItem;

this.gameObject = nil;
this.transform = nil;
this.LuaBehaviour = nil;

this.txtTitle = nil;
---@type UnityEngine.GUIText
this.txtContent = nil;
this.txtLockTip = nil;
this.lockCtrl = nil

function UICharactorInfoArchivesItem.Init()--todo 应该小写 暂时先大写
    local name = getUIName(PanelNames.UICharactorInfoArchivesItem);
    panelMgr:ShowUI(name, this.onCreate, Config.useLocalUI);
end

function UICharactorInfoArchivesItem.onCreate()
    obj:SetActive(false);
end
---@param obj FairyGUI.GComponent
function UICharactorInfoArchivesItem.initData(obj,data,luaBehaviour)
    --LuaBehaviour = luaBehaviour;
    --gameObject = obj;
    --transform = obj.transform;

    txtTitle = obj:GetChild("titleText")
    txtContent = obj:GetChild("infoText")
    txtLockTip = obj:GetChild("LockTip")
    lockCtrl = obj:GetController("lock")
    
    local isUnlock = data.unLock;
    local content = data.content;
    local title = data.title;

    txtTitle.text = title;
    txtLockTip.visible = not isUnlock
    txtContent.visible = isUnlock

    local height =0;
    if isUnlock then
        lockCtrl.selectedIndex = 1
        txtContent.text = content;
        height = -txtContent.position.y+ txtContent.height+150;
    else
        lockCtrl.selectedIndex = 0
        txtLockTip.text = content;
        height = -txtLockTip.position.y+ txtLockTip.height+150;
    end
    return height;
end



return UICharactorInfoArchivesItem;
